/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhanguera.tcc.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "tb_contrato")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contrato.findAll", query = "SELECT c FROM Contrato c"),
    @NamedQuery(name = "Contrato.findByIdContrato", query = "SELECT c FROM Contrato c WHERE c.idContrato = :idContrato"),
    @NamedQuery(name = "Contrato.findByNuContrato", query = "SELECT c FROM Contrato c WHERE c.nuContrato = :nuContrato"),
    @NamedQuery(name = "Contrato.findByVlContrato", query = "SELECT c FROM Contrato c WHERE c.vlContrato = :vlContrato"),
    @NamedQuery(name = "Contrato.findByDtInicioVigencia", query = "SELECT c FROM Contrato c WHERE c.dtInicioVigencia = :dtInicioVigencia"),
    @NamedQuery(name = "Contrato.findByDtFimVigencia", query = "SELECT c FROM Contrato c WHERE c.dtFimVigencia = :dtFimVigencia"),
    @NamedQuery(name = "Contrato.findByTxDescricaoObjeto", query = "SELECT c FROM Contrato c WHERE c.txDescricaoObjeto = :txDescricaoObjeto"),
    @NamedQuery(name = "Contrato.findByInSituacao", query = "SELECT c FROM Contrato c WHERE c.inSituacao = :inSituacao")})
public class Contrato implements Serializable {

    @ManyToMany(mappedBy = "contratoList")
    private List<ContratadaPj> contratadaPjList;

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_CONTRATO")
    private Integer idContrato;
    @Basic(optional = false)
    @Column(name = "NU_CONTRATO")
    private String nuContrato;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @Column(name = "VL_CONTRATO")
    private BigDecimal vlContrato;
    @Basic(optional = false)
    @Column(name = "DT_INICIO_VIGENCIA")
    @Temporal(TemporalType.DATE)
    private Date dtInicioVigencia;
    @Basic(optional = false)
    @Column(name = "DT_FIM_VIGENCIA")
    @Temporal(TemporalType.DATE)
    private Date dtFimVigencia;
    @Basic(optional = false)
    @Column(name = "IN_SITUACAO")
    private String inSituacao;
    @Basic(optional = false)
    @Column(name = "TX_DESCRICAO_OBJETO")
    private String txDescricaoObjeto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codContrato")
    private List<ComprovanteEntrega> comprovanteEntregaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codContrato")
    private List<NotificacaoAutomatica> notificacaoAutomaticaList;
    @OneToMany(mappedBy = "codContrato")
    private List<Ocorrencia> ocorrenciaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codContrato")
    private List<AnexoContrato> anexoContratoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codContrato")
    private List<ItemContrato> itemContratoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codContrato")
    private List<Empenho> empenhoList;

    public Contrato() {
    }

    public Contrato(Integer idContrato) {
        this.idContrato = idContrato;
    }

    public Contrato(Integer idContrato, String nuContrato, BigDecimal vlContrato, Date dtInicioVigencia, Date dtFimVigencia, String inSituacao, String txDescricaoObjeto) {
        this.idContrato = idContrato;
        this.nuContrato = nuContrato;
        this.vlContrato = vlContrato;
        this.dtInicioVigencia = dtInicioVigencia;
        this.dtFimVigencia = dtFimVigencia;
        this.inSituacao = inSituacao;
        this.txDescricaoObjeto = txDescricaoObjeto;
    }

    public Integer getIdContrato() {
        return idContrato;
    }

    public void setIdContrato(Integer idContrato) {
        this.idContrato = idContrato;
    }

    public String getNuContrato() {
        return nuContrato;
    }

    public void setNuContrato(String nuContrato) {
        this.nuContrato = nuContrato;
    }

    public BigDecimal getVlContrato() {
        return vlContrato;
    }

    public void setVlContrato(BigDecimal vlContrato) {
        this.vlContrato = vlContrato;
    }

    public Date getDtInicioVigencia() {
        return dtInicioVigencia;
    }

    public void setDtInicioVigencia(Date dtInicioVigencia) {
        this.dtInicioVigencia = dtInicioVigencia;
    }

    public Date getDtFimVigencia() {
        return dtFimVigencia;
    }

    public void setDtFimVigencia(Date dtFimVigencia) {
        this.dtFimVigencia = dtFimVigencia;
    }

    public String getInSituacao() {
        return inSituacao;
    }

    public void setInSituacao(String inSituacao) {
        this.inSituacao = inSituacao;
    }

    public String getTxDescricaoObjeto() {
        return txDescricaoObjeto;
    }

    public void setTxDescricaoObjeto(String txDescricaoObjeto) {
        this.txDescricaoObjeto = txDescricaoObjeto;
    }

    @XmlTransient
    public List<ComprovanteEntrega> getComprovanteEntregaList() {
        return comprovanteEntregaList;
    }

    public void setComprovanteEntregaList(List<ComprovanteEntrega> comprovanteEntregaList) {
        this.comprovanteEntregaList = comprovanteEntregaList;
    }

    @XmlTransient
    public List<NotificacaoAutomatica> getNotificacaoAutomaticaList() {
        return notificacaoAutomaticaList;
    }

    public void setNotificacaoAutomaticaList(List<NotificacaoAutomatica> notificacaoAutomaticaList) {
        this.notificacaoAutomaticaList = notificacaoAutomaticaList;
    }

    @XmlTransient
    public List<Ocorrencia> getOcorrenciaList() {
        return ocorrenciaList;
    }

    public void setOcorrenciaList(List<Ocorrencia> ocorrenciaList) {
        this.ocorrenciaList = ocorrenciaList;
    }

    @XmlTransient
    public List<AnexoContrato> getAnexoContratoList() {
        return anexoContratoList;
    }

    public void setAnexoContratoList(List<AnexoContrato> anexoContratoList) {
        this.anexoContratoList = anexoContratoList;
    }

    @XmlTransient
    public List<Empenho> getEmpenhoList() {
        return empenhoList;
    }

    public List<ItemContrato> getItemContratoList() {
        return itemContratoList;
    }

    public void setItemContratoList(List<ItemContrato> itemContratoList) {
        this.itemContratoList = itemContratoList;
    }

    public void setEmpenhoList(List<Empenho> empenhoList) {
        this.empenhoList = empenhoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idContrato != null ? idContrato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contrato)) {
            return false;
        }
        Contrato other = (Contrato) object;
        if ((this.idContrato == null && other.idContrato != null) || (this.idContrato != null && !this.idContrato.equals(other.idContrato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.anhanguera.tcc.model.Contrato[ idContrato=" + idContrato + " ]";
    }

    @XmlTransient
    public List<ContratadaPj> getContratadaPjList() {
        return contratadaPjList;
    }

    public void setContratadaPjList(List<ContratadaPj> contratadaPjList) {
        this.contratadaPjList = contratadaPjList;
    }

}
